package com.boroborome.convert;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

public class StatisticItemCalculator {
    private Map<String, StatisticItemBuilder> builderMap = new HashMap<>();

    public void accept(ICallRecord record) {
        StatisticItemBuilder builder = builderMap.computeIfAbsent(record.getFunctionId(), StatisticItemBuilder::new);
        builder.acceptRecord(record);
    }

    public Stream<StatisticItem> statisticItemStream() {
        return builderMap.values().stream()
                .map(StatisticItemBuilder::build);
    }
}
